package org.dtrd.modules.control.entity.po;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.dtrd.modules.control.entity.bean.TargetAndDetailInfo;
import org.dtrd.modules.control.entity.bean.TargetInfo;

import java.io.Serializable;
import java.util.Date;

/**
 * 控制目标记录
 * @TableName dtrd_ent_rd_signin_target
 */
@TableName(value ="dtrd_ent_rd_signin_target")
@Data
@Slf4j
public class DtrdEntRdSigninTarget implements Serializable {
    /**
     * 
     */
    @TableId(type = IdType.AUTO)
    private Integer dataId;

    /**
     * 患者id
     */
    private Integer patientId;

    /**
     * 控制目标名称
     */
    private String targetName;

    /**
     * 开始日期
     */
    private Date startDate;

    /**
     * 结束日期
     */
    private Date endDate;

    /**
     * 当前使用状态1-使用中,0-未使用
     */
    private Integer currentStatus;

    /**
     * 
     */
    private Date createTime;

    /**
     * 
     */
    @TableLogic
    private Integer isDel;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    public DtrdEntRdSigninTarget init() {
        this.setIsDel(0);
        this.setCreateTime(new Date());
        this.setCurrentStatus(1);
        return this;
    }

    public DtrdEntRdSigninTarget parseFromDTO(TargetAndDetailInfo dto) {
        dataId = dto.getTargetId();
        startDate = dto.getStartDate();
        endDate = dto.getEndDate();
        targetName = dto.getTargetName();
        patientId = dto.getPatientId();
        return this;
    }

    public DtrdEntRdSigninTarget parseFromDTO(TargetInfo dto) {
        this.setDataId(dto.getDataId());
        this.setTargetName(dto.getTargetName());
        this.setStartDate(dto.getStartDate());
        this.setEndDate(dto.getEndDate());
        this.setCurrentStatus(dto.getCurrentStatus());
        return this;
    }
}